using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace MT5Trade.Models.MarketData
{
    /// <summary>
    /// 市场数据提供者接口
    /// </summary>
    public interface IMarketDataProvider
    {
        /// <summary>
        /// 获取历史数据
        /// </summary>
        /// <param name="symbol">交易品种</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="interval">时间间隔</param>
        /// <returns>历史行情数据列表</returns>
        Task<List<MarketTick>> GetHistoricalDataAsync(
            string symbol,
            DateTime startDate,
            DateTime endDate,
            Interval interval = Interval.Daily);

        /// <summary>
        /// 获取最新报价
        /// </summary>
        /// <param name="symbol">交易品种</param>
        /// <returns>最新行情数据</returns>
        Task<MarketTick> GetLatestQuoteAsync(string symbol);

        /// <summary>
        /// 批量获取多个品种的最新报价
        /// </summary>
        /// <param name="symbols">交易品种列表</param>
        /// <returns>品种与行情的映射</returns>
        Task<Dictionary<string, MarketTick>> GetMultipleQuotesAsync(List<string> symbols);

        /// <summary>
        /// 计算波动率
        /// </summary>
        /// <param name="symbol">交易品种</param>
        /// <param name="lookbackDays">回看天数</param>
        /// <returns>波动率数据</returns>
        Task<MarketVolatility> CalculateVolatilityAsync(
            string symbol,
            int lookbackDays = 20);

        /// <summary>
        /// 识别缺口
        /// </summary>
        /// <param name="symbol">交易品种</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="minGapPercentage">最小缺口百分比</param>
        /// <returns>缺口事件列表</returns>
        Task<List<GapEvent>> IdentifyGapsAsync(
            string symbol,
            DateTime startDate,
            DateTime endDate,
            double minGapPercentage = 0.01);

        /// <summary>
        /// 计算相关性矩阵
        /// </summary>
        /// <param name="symbols">交易品种列表</param>
        /// <param name="lookbackDays">回看天数</param>
        /// <returns>相关性矩阵</returns>
        Task<Dictionary<string, double>> CalculateCorrelationMatrixAsync(
            List<string> symbols,
            int lookbackDays = 30);

        /// <summary>
        /// 获取市场状态
        /// </summary>
        /// <param name="symbol">交易品种</param>
        /// <returns>市场状态</returns>
        Task<MarketRegime> GetMarketRegimeAsync(string symbol);

        /// <summary>
        /// 批量获取历史数据（优化批量请求）
        /// </summary>
        /// <param name="symbols">交易品种列表</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns>品种与历史数据的映射</returns>
        Task<Dictionary<string, List<MarketTick>>> GetBulkHistoricalDataAsync(
            List<string> symbols,
            DateTime startDate,
            DateTime endDate);
    }
}